import MyTable from '@/components/MyTable';
import { editWalletReChange } from '@/services/users';
import React from 'react';

import FormModalBtn from '@/components/FormModalBtn';
import { getResult } from '@/services/sys/attribute';
import { findByWalletBackLogList } from '@/services/sys/log';
const btnColmuns = [
  {
    title: 'userId',
    dataIndex: 'userId',
    key: 'userId',
    width: 'md',
    readonly: true,
    formItemProps: {
      hidden: true,
    },
  },
  {
    title: '姓名',
    dataIndex: 'name',
    key: 'name',
    width: 'md',
    readonly: true,
  },
  {
    title: '财务动作',
    dataIndex: 'state',
    key: 'state',
    width: 'md',
    valueType: 'select',
    valueEnum: await getResult('usersblancewithdrawaltype', 0),
    formItemProps: {
      debounceTime: 300,
      rules: [
        {
          required: true,
        },
      ],
    },
  },
  {
    title: '金额',
    dataIndex: 'price',
    key: 'price',
    width: 'md',
    valueType: 'money',
    fieldProps: {
      help: 'gggggggggggggggggggggggg',
    },
    formItemProps: {
      rules: [
        {
          required: true,
        },
      ],
    },
  },
  {
    title: '处理类型',
    dataIndex: 'type',
    key: 'type',
    width: 'md',
    valueType: 'select',
    valueEnum: await getResult('userswithdrawaltype', 0),
    formItemProps: {
      debounceTime: 300,
      rules: [
        {
          required: true,
        },
      ],
    },
  },
  {
    title: '备注',
    dataIndex: 'remark',
    key: 'remark',
    width: 'md',
    valueType: 'textarea',
    //@ts-ignore
    formItemProps: {
      rules: [
        {
          required: true,
        },
      ],
    },
  },
];
const FinanceSetting: React.FC<any> = (props) => {
  const { user } = props;
  const colmuns = [
    {
      title: '编号',
      key: 'id',
      dataIndex: 'id',
      search: false,
    },
    {
      title: '用户姓名',
      key: 'name',
      dataIndex: 'name',
      search: false,
    },
    {
      title: '动作',
      key: 'stateName',
      dataIndex: 'stateName',
      search: false,
    },
    {
      title: '操作帐户',
      key: 'type',
      dataIndex: 'type',
      valueType: 'select',
      valueEnum: getResult('userswithdrawaltype', 0),
      search: false,
    },
    {
      title: '操作金额',
      key: 'price',
      dataIndex: 'price',
      valueType: 'money',
      search: false,
    },
    {
      title: '当前余额',
      key: 'balance',
      dataIndex: 'balance',
      valueType: 'money',
      search: false,
    },
    {
      title: '详细说明',
      key: 'remark',
      dataIndex: 'remark',
      search: false,
    },
    {
      title: '申请时间',
      key: 'create_date',
      dataIndex: 'create_date',
      valueType: 'dateTime',
    },
    {
      title: '操作员',
      key: 'operatorName',
      dataIndex: 'operatorName',
      search: false,
    },
  ];
  // @ts-ignore
  // @ts-ignore
  let toolbar = [
    <FormModalBtn
      initialValues={{ name: user?.name, userId: user?.id }}
      title="财务调整"
      btnText="财务调整"
      columns={btnColmuns}
      request={editWalletReChange}
    />,
  ];
  return (
    <MyTable
      toolbar={() => toolbar}
      params={{ userId: user.id }}
      request={findByWalletBackLogList}
      columns={colmuns}
    />
  );
};

export default FinanceSetting;
//96, 100, 104, 105, 107.239, 230, 361, 1161, 1162, 1148, 238
